﻿<phone:PhoneApplicationPage 
    x:Class="Cnblogs.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
    xmlns:delay="clr-namespace:Cnblogs"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="696"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientations="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <phone:PhoneApplicationPage.Resources>
        <DataTemplate x:Key="DT_HomeFeed">
            <StackPanel>
                <Grid x:Name="grd" Margin="0,0,0,20" Tap="HomeFeed_Tap">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="auto"/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <Image x:Name="imgAvatar" delay:LowProfileImageLoader.UriSource="{Binding AuthorInfo.Avatar}" 
                       Source="/Images/DefaultProfile.png"
                       Grid.Column="0"
                       Tap="imgAvatar_Tap"
                       Margin="0,0,12,0"
                       Height="48" Width="48" />
                    <StackPanel Grid.Column="1" >
                        <TextBlock Text="{Binding TitleDisplay}" FontSize="24" Width="384" FontWeight="Bold" />
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="作者：" FontWeight="Bold" />
                            <TextBlock Text="{Binding AuthorInfo.Name}" FontWeight="Bold" />
                        </StackPanel>
                    </StackPanel>
                    <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Summary}" HorizontalAlignment="Left" TextWrapping="Wrap" Width="384"/>
                    <StackPanel Grid.Column="1" Grid.Row="2" Orientation="Horizontal">
                        <TextBlock Text="评论(" Foreground="{StaticResource PhoneSubtleBrush}"/>
                        <TextBlock x:Name="tbk_comments" Text="{Binding Comments}" FontWeight="Bold" VerticalAlignment="Center" />
                        <TextBlock Text=") 阅读(" Foreground="{StaticResource PhoneSubtleBrush}"/>
                        <TextBlock x:Name="tbk_views" Text="{Binding Views}" FontWeight="Bold" VerticalAlignment="Center" />
                        <TextBlock Text=") " Foreground="{StaticResource PhoneSubtleBrush}"/>
                        <TextBlock Text="{Binding Published}" Foreground="{StaticResource PhoneSubtleBrush}"/>
                    </StackPanel>
                </Grid>
                <Button Content="加载更多..." Click="btn_loadmore_click" Visibility="{Binding LoadMoreVisibility}" BorderThickness="0" Height="70"/>
            </StackPanel>
        </DataTemplate>
        <DataTemplate x:Key="DT_Feed">
            <Grid x:Name="grd" Margin="0,0,0,20" Tap="SelectItem_Tap">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="auto"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBlock Text="{Binding TitleDisplay}" FontSize="24" FontWeight="Bold" />
                <TextBlock Grid.Row="1" Text="{Binding Summary}" HorizontalAlignment="Left" TextWrapping="Wrap" Width="432"/>
                <StackPanel Grid.Row="2" Orientation="Horizontal">
                    <TextBlock Text="评论(" Foreground="{StaticResource PhoneSubtleBrush}"/>
                    <TextBlock x:Name="tbk_comments" Text="{Binding Comments}" FontWeight="Bold" VerticalAlignment="Center" />
                    <TextBlock Text=") 阅读(" Foreground="{StaticResource PhoneSubtleBrush}"/>
                    <TextBlock x:Name="tbk_views" Text="{Binding Views}" FontWeight="Bold" VerticalAlignment="Center" />
                    <TextBlock Text=") 来源：" Foreground="{StaticResource PhoneSubtleBrush}"/>
                    <TextBlock Text="{Binding SourceName}" Foreground="{StaticResource PhoneSubtleBrush}"/>
                </StackPanel>
                <StackPanel Grid.Row="3"  Orientation="Horizontal">
                    <TextBlock Text="发表于：" Foreground="{StaticResource PhoneSubtleBrush}"/>
                    <TextBlock Text="{Binding Published}" Foreground="{StaticResource PhoneSubtleBrush}"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
    </phone:PhoneApplicationPage.Resources>

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <!--Pivot Control-->
        <toolkit:LockablePivot Title="博客园" Name="pivot" SelectionChanged="pivot_SelectionChanged">
            <controls:PivotItem Header="首页">
                <ListBox x:Name="lbx_home" 
                         Margin="12,0,0,0"
                         ItemTemplate="{StaticResource DT_HomeFeed}" >
                </ListBox>
            </controls:PivotItem>
            <controls:PivotItem Header="最新新闻">
                <ListBox x:Name="lbx_recent" 
                         Margin="12,0,0,0"
                         ItemTemplate="{StaticResource DT_Feed}" >
                </ListBox>
            </controls:PivotItem>

            <controls:PivotItem Header="推荐新闻">
                <ListBox x:Name="lbx_recommend" 
                         Margin="12,0,0,0"
                         ItemTemplate="{StaticResource DT_Feed}">
                </ListBox>
            </controls:PivotItem>

            <controls:PivotItem Header="热门新闻">
                <ListBox x:Name="lbx_hot" 
                         Margin="12,0,0,0"
                         ItemTemplate="{StaticResource DT_Feed}">
                </ListBox>
            </controls:PivotItem>
        </toolkit:LockablePivot>
    </Grid>

    <!--Sample code showing usage of ApplicationBar-->
    <phone:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_refresh.png" Text="刷新" Click="Appbar_Refresh_Click"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_share.png" Text="评分" Click="Appbar_Review_Click"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_search.png" Text="搜博主" Click="Appbar_Search_Click"/>
            <shell:ApplicationBarIconButton IconUri="/Images/appbar_lock.png" Text="锁定" Click="Appbar_Lock_Click"/>
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem Text="设置" Click="menu_setting_Click"/>
                <shell:ApplicationBarMenuItem Text="关于" Click="menu_about_Click" />
            </shell:ApplicationBar.MenuItems>
        </shell:ApplicationBar>
    </phone:PhoneApplicationPage.ApplicationBar>

</phone:PhoneApplicationPage>